<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>

var lengthOfLongestSubstring = function(s) {
    let l = 0
    let res = 0
    let map = new Map()
    for( let r = 0 ; r<s.length ; r++ ){
        if( map.has(s[r]) && map.get(s[r]) >= l ){
            l = map.get(s[r])+1
        }
        res = Math.max( res , r-l+1 )
        map.set(s[r] , r)
    }
    return res
};


</script>
</body>
</html>